import Vue from 'vue';
import store from '../../../../index';
export default {
    /*获取*/
    playChannelApi(state,obj){
        let storeId = obj.storeId || 0;
        let userId = obj.userId || 0
        let thirdId = obj.thirdId || 0
        let params ={
            userId
        }
        let that = this;
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/cloud/play/direct/get/store/${storeId}/channel`;
        console.log(obj,'successFn')
        Vue.prototype.xurl.postLoading(url,params).then((data) => {
            // state.playChannelMsg = data.result;
            let tempObj = Object.assign({},obj,data.result);
            store.commit('playthemeApi',tempObj)
        })
    },
    /*/cloud/play/direct/channel/{channelId}/theme/get/newest*/
    playthemeApi(state,obj){
        let channelId = obj.channelId;
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/cloud/play/direct/channel/${channelId}/theme/get/newest`;
        Vue.prototype.xurl.getLoading(url).then((data) => {
            /*使用https域名这里就要转换成https*/
            let tempObj = {
                poster:data.result && data.result.poster ? data.result.poster : '',
                hlsPullUrl:obj.hlsPullUrl.replace('http','https'),
                httpPullUrl:obj.httpPullUrl.replace('http','https'),
                rtmpPullUrl:obj.rtmpPullUrl.replace('http','https'),
            }
            state.playChannelMsg = Object.assign({},obj,tempObj);
            if(obj.successFn){
                obj.successFn(data);
            }
            // console.log(state.playChannelMsg )
        })
    },

}